var http=require("http"),
var path=require("path"),
var fs=require("fs"),
mime=require("mime");

http.createServer((req,res)=>{
res.render=function(filename){

}

    req.url=req.url.toLowerCase(),req.method=req.method.toLowerCase();
    if (req.url==="/"||req.url==="/index"&&req.method==="get") {
        fs.readFile(path.join(__dirname,"view","index.html"),(err,data)=>{
            if (err) {
                throw err;
            }else{
                
                res.end(data);
            }
        });
    }else if (req.url==="/submit"&&req.method==="get") {
        
    }else if (req.url==="/item"&&req.method==="get") {
        
    }else if(req.url==="/add"&&req.method==="get"){

    }else if (req.url==="/add"&&req.method==="post") {
        
    }else{
        res.writeHead(404,"not found",{
            "Content-Type":"text/html;charset=utf-8"
        });
    }
    res.end("404,not found page")



    var publicDir=path.join(__dirname,"public"),
    filename=path.join(publicDir,req.url);
    fs.readFile(filename,(err,data)=>{
        if (err) {
            res.end("not found 404");
        }else{
            res.setHeader("Content-Type",mime.getType(filename));
            
            res.end(data);
        }
    });
}).listen(5000,()=>{
    console.log("http://localhost:5000");
});